<template>
  <div  class="boxdiv">
    <scroller :on-refresh="refresh">
      <div class="category-wrap">
        <ul class="nav-side">
          <li
            v-for="(item, index) in list"
            :key="item.id"
            @click="getIndex(index)"
            :class="{ bgc: temp === index }"
          >
            {{ item.name }}
          </li>
        </ul>
      </div>
    </scroller>

    <div>
        <scroller :on-refresh="refresh" class="headerscroller">
      <div
        v-for="(item, index) in list"
        :key="item.id"
        class="headerimg"
        v-show="temp == index"
      >
        <div>
          <img :src="item.mainImgUrl" alt="" />
        </div>

        <div v-for="item in item.list" :key="item.id">
          <p class="pone">{{ item.title }}</p>
          <div>
            <div class="phone">
              <div v-for="item in item.productList" :key="item.id">
                <img class="imgfla" :src="item.imgUrl" alt="" />
                <p>{{ item.title }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </scroller>

    </div>
  </div>
</template>
<script>
export default {
  created() {
    this.getIist();
  },
  data() {
    return {
      list: [],
      temp: 0,
    };
  },

  methods: {
    refresh() {},
    getIndex(index) {
      this.temp = index;
    },
    async getIist() {
      const res = await this.$require({
        url: "/category/data",
        method: "get",
      });
      if (res.status == 200) {
        this.list = res.data.data;
        //  this.list.push(res.data.data)
        // console.log(this.list);
      }
    },
  },
};
</script>

<style lang="scss" scoped>

.boxdiv{
  height: 812px;
}
.category-wrap {
  // margin-top: 70px;
  .nav-side {
    width: 46px;
    li {
      width: 112.5px;
      line-height: 46px;
      text-align: center;
      color: #000000;
      background-color: #f8f8f8;
    }
    .bgc {
      background-color: #fff;
      color: #f8f8f8;
      color: #000000;
    }
  }
}

.headerscroller{
   width: 152px;
   height: 100%;
  position: relative;
  top: 70px;
  left: 100px;
  padding: 0px 5px;
}
.headerimg {
  width: 252px;
  margin-left: 10px;
  padding: 0px 5px;
  // background-color: chartreuse;
  div {
    padding: 0;
    margin: 0;
    img {
      width: 242px;
    }
  }
}
.pone {
  width: 250px;
  color: #000000;
  font-size: 17px;
  // padding: 20px 0px;
  // background-color: chocolate;
}
.phone {
  width: 255px;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  div {
    width: 33%;
    // height: 45%;
    img {
      width: 80px;
      height: 80px;
    }
    p {
      font-size: 15px;
      text-align: center;
    }
  }
}
.nav-side{
  width: 250px;
}
</style>